package com.leisure.mappers;

import com.leisure.pojo.TUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * ClassName: UserMapper
 * Package: com.leisure.mapper
 * Description:
 *
 * @Author: MyLeisureLife
 * @Date: 2024/6/5:01:11:09 星期三
 */
@Mapper
public interface UserMapper {
    //根据用户名查询用户
    @Select("SELECT * FROM t_user WHERE username=#{username}")
    TUser findByUserName(String username);

    //添加
    @Insert("INSERT INTO t_user(username, password,create_time, update_time)" +
            " values(#{username},#{password},NOW(),NOW())")
    void add(String username, String password);

    //跟新数据
    @Update("UPDATE t_user SET nickname=#{nickname}, email=#{email}, update_time=#{updateTime} WHERE id=#{id}")
    void update(TUser user);
}
